package com.sure.service;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import com.sure.bean.LoginDto;
import com.sure.bean.User;
import com.sure.util.Utils;

public class LoginService {

	public User login(LoginDto dto) {
		
		QueryRunner runner = new QueryRunner(Utils.getDataSource());
		
		try {
			String sql = "select u_id,u_name from t_user where u_id = ? and u_pwd = ?";
			User user = runner.query(sql, new BeanHandler<>(User.class),dto.getU_id(),dto.getU_pwd());
			return user;		
		}catch(Exception e) {
			throw new RuntimeException(e);
		}
		
		
	}

}
